package huzh.foundation.dao;

import java.util.ArrayList;

/**
 *<p>title:DAOParamGenerator</p>
 *<p>description:</p>
 * @since 2014-6-8
 * @author huzh
 * @version 1.0
 */
public class DAOParamGenerator {
    /**dAOParam*/
    private ArrayList<Object> dAOParam = new ArrayList<Object>();

    /**
     * @return
     */
    public ArrayList<Object> getDAOParam() {
        return this.dAOParam;
    }

    /**
     * @param param
     */
    public void addFirstSqlParam(Object param) {
        addSqlParam(0, param);
    }

    /**
     * @param index
     * @param param
     */
    @SuppressWarnings("unchecked")
    public void addSqlParam(int index, Object param) {
        int end = index + 1 - this.dAOParam.size();
        for (int i = 0; i < end; i++) {
            this.dAOParam.add(new ArrayList<Object>());
        }
        ((ArrayList)this.dAOParam.get(index)).add(param);
    }

    /**
     * @param sqlIndex
     */
    public void intSqlParam(int sqlIndex) {
        int end = sqlIndex + 1 - this.dAOParam.size();
        for (int i = 0; i < end; i++)
            this.dAOParam.add(new ArrayList<Object>());
    }

    /**
     * @param sqlIndex
     * @param rowIndex
     * @param param
     */
    @SuppressWarnings("unchecked")
    public void addBatchSqlParam(int sqlIndex, int rowIndex, Object param){
        int size = this.dAOParam.size();
        for (int i = 0; i < sqlIndex - size + 1; i++) {
            this.dAOParam.add(new ArrayList<Object>());
        }
        ArrayList<Object> al = (ArrayList)this.dAOParam.get(sqlIndex);
        for (int i = 0; i < rowIndex + 1 - al.size(); i++) {
            al.add(new ArrayList());
        }
        ((ArrayList)al.get(rowIndex)).add(param);
    }
}
